package com.chukun.interview.feature.inf.impl;

import com.chukun.interview.feature.inf.base.Shape;

// 使用java的档案类声明不可变对象: 圆形
public record Circle04(double radius) implements Shape {

    // 对半径做一些校验，如何重写构造方法
    public Circle04 {
        if (radius < 0) {
            throw new IllegalArgumentException("The radius of a circle cannot be negative [" + radius + "]");
        }
    }

    @Override
    public double getArea() {
        return Math.PI * radius * radius;
    }
}
